import "package:ct_pa_majordomo/utils/request.dart";
import "package:dio/dio.dart";

class CheckInApi {
  Future<Map> getCheckInInfo({required int checkInId}) async {
    Response response = await request.get(
      "apartment/check-in/$checkInId",
    );
    return response.data ?? {};
  }

  Future<Map> updateCheckIn(data) async {
    Response response = await request.put(
        "apartment/check-in",
        data: data
    );
    return response.data ?? {};
  }

  Future<Map> updateRenter(data) async {
    Response response = await request.put(
      "apartment/renter",
      data: data
    );
    return response.data ?? {};
  }

  Future<Map> addRenter(data) async {
    Response response = await request.post(
        "apartment/renter",
        data: data
    );
    return response.data ?? {};
  }

  Future<Map> removeRenter(String renterIds) async {
    Response response = await request.delete(
        "apartment/renter/$renterIds",
    );
    return response.data ?? {};
  }

  /// 获取入住记录
  Future<Map> getCheckInRecord(int roomId) async {
    Response response = await request.get(
      "apartment/check-in/list",
      queryParameters: { "roomId": roomId }
    );
    return response.data ?? {};
  }

  /// 验证身份信息
  Future<Map> verifyInfo(int renterId, data) async {
    Response response = await request.post(
        "apartment/renter/verify/$renterId",
        queryParameters: data
    );
    return response.data ?? {};
  }

  /// 根据房间id获取用电记录
  Future<Map> getEleRecordByRoomId(int roomId, data) async {
    Response response = await request.get(
        "apartment/record/list/room/$roomId",
        queryParameters: data
    );
    return response.data ?? {};
  }
}

CheckInApi checkInApi = CheckInApi();